<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane  aaaaa" id="commentForm">
    <div class="page-title">
        <div class="page-title-con">
            <span>查看备案人员</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
<!--                <button type="button" class="layui-btn layui-btn-sm btn-dark marginr5" lay-submit="" lay-filter="add">提交</button>-->
                <span id="page-close" class="page-close" onclick="layer_close()"><i class="layui-icon layui-icon-close"></i></span>
            </div>

        </div>
    </div>
    <div class="main-container">

        <div class="block-first">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" autocomplete="off" disabled class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div class="block-generic">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="1">
                    <div class="opt-btn-group">
                        <div><span>在用备案人员</span></div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>岗位</th>
                            <th>证书名称</th>
                            <th>证书编号</th>
                            <th>证书专业</th>
                            <th>持证人</th>
                            <th>是否锁证</th>
                            <th>锁证开始</th>
                            <th>锁证结束</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="zai_list"></tbody>
                    </table>
                </div>

                <div class="short_table_list" key="2" style="margin-top: 20px;">
                    <div class="opt-btn-group">
                        <div><span>已变更备案人员</span></div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th width="45">序号</th>
                            <th>岗位</th>
                            <th>证书名称</th>
                            <th>证书编号</th>
                            <th>证书专业</th>
                            <th>持证人</th>
                            <th>是否锁证</th>
                            <th>锁证开始</th>
                            <th>锁证结束</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody" id="change_list"></tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;

    layui.use(['laytp', 'form'], function() {
        var form = layui.form;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_engin_beian, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#name").val(data.name);

                var list = res.data.list;
                var zai_str = ''; var change_str = '';
                for (var key in list){
                    var nums = parseInt(key)+1;
                    var str = '';
                    str += '<tr>';
                    str += '<td style="width: 45px">'+nums+'</td>';
                    str += '<td>'+list[key].place+'</td>';
                    str += '<td>'+list[key].cert_name+'</td>';
                    str += '<td>'+list[key].cert_number+'</td>';
                    str += '<td>'+list[key].cert_major+'</td>';
                    str += '<td>'+list[key].person_name+'</td>';
                    str += '<td>';
                    str += '<select class="layui-select issuo">';
                    str += '<option value="">请选择</option>';
                    if(list[key].issuo == '1'){
                        str += '<option value="1" selected>是</option>';
                        str += '<option value="2">否</option>';
                    }else if(list[key].issuo == '2'){
                        str += '<option value="1">是</option>';
                        str += '<option value="2" selected>否</option>';
                    }else{
                        str += '<option value="1">是</option>';
                        str += '<option value="2">否</option>';
                    }
                    str += '</select>';
                    str += '</td>';
                    str += '<td>' +
                        '<input type="hidden" class="layui-input id" value="'+list[key].id+'">' +
                        '<input type="text" class="layui-input startdt bdate_ymd" value="'+list[key].startdt+'" readonly></td>';
                    str += '<td><input type="text" class="layui-input enddt bdate_ymd" value="'+list[key].enddt+'" readonly></td>';
                    str += '<td><input type="text" class="layui-input explain" value="'+list[key].explain+'"></td>';
                    str += '</tr>';
                    if(list[key].pid === 0 && list[key].isdel === 0){
                        zai_str += str;
                    }else{
                        change_str += str;
                    }
                }
                $("#zai_list").append(zai_str);
                $("#change_list").append(change_str);
                render_date();
                render_from();
            }
        });



        form.on('submit(add)', function(data){
            var list = [''];
            $('.short_table_tbody tr').each(function (i) {
                var id = $(this).find('.id').val();
                var issuo = $(this).find('.issuo').val();
                var startdt = $(this).find('.startdt').val();
                var enddt = $(this).find('.enddt').val();
                var explain = $(this).find('.explain').val();
                list.push({
                    id:id,
                    issuo:issuo,
                    startdt:startdt,
                    enddt:enddt,
                    explain:explain,
                });
            });
            data.field.list = list;

            data.field.id = param_id;
            facade.ajax({url: ask_engin_beian, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });




</script>
</body>
</html>
